<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use App\Models\User;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->comment('账号');
            $table->char('mobile',11)->unique()->comment('手机号码');
            $table->string('email')->unique()->comment('邮箱');
            $table->string('password')->comment('密码');
            $table->rememberToken();
            $table->timestamps();
        });

        $now = Carbon\Carbon::now();
        User::create(
            [
                'name' => env('APP_AUTH_USER', 'jiuyou'),
                'email' => 'jian34long@163.com',
                'mobile' => '18702629928',
                'password' => bcrypt('123456'),
                'created_at' => $now,
                'updated_at' => $now
            ]
        );

    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
